package com.salesmanager.core.modules.cms.product;

import com.salesmanager.core.constants.Constants;
import com.salesmanager.core.modules.cms.aliyun.OSSClientFactory;
import com.salesmanager.core.utils.CoreConfiguration;

/**
 * Created by Liutong on 9/14/15.
 * 文件管理工厂
 * 根据CMS_SERVER配置获得不同实现
 */
public class CmsFileManagerFactory {

    private CmsFileManagerFactory(){

    }

    private static CmsImageFileManager cmsImageFileManager;


    public static  CmsImageFileManager getInstance(CoreConfiguration configuration,OSSClientFactory ossClientFactory,String rootName){
        if (cmsImageFileManager == null){
            if (configuration.getProperty(Constants.CMS_SERVER) == null || configuration.getProperty(Constants.CMS_SERVER).equals(Constants.CMS_SERVER_LOCAL)){
//                cmsImageFileManager = new CmsImageFileManagerInfinispanImpl(rootName,null,configuration);
            }else{
                cmsImageFileManager = new CmsImageFileManagerOssImpl(ossClientFactory,configuration);
            }
        }
        return cmsImageFileManager;
    }
}
